<?php
/**
 * User: WL
 * Time: 12-10-13 - 上午9:14
 * File: list.inc.php
 * Project For ixdcw.com
 */
/**
 * 2013-4-1 Sameal add order by cityid an group level
 */
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.$module.'/common.inc.php';
require_once DT_INC.'/post.func.php';
//引用公共头部模版
require DT_CORE.'/buyhelp/common.inc.php';
$navname='price';
ViewCheck::catExists() or Prompt::listNotFound();
ViewCheck::groupListPermission() or Prompt::noPermission();
$TYPES = explode('|', $MOD['type']);
// normal
$filter['catid']  = getgpc('catid');
$filter['areaid'] = getgpc('areaid');
$filter['typeid'] = getgpc('typeid');

// auto
$filter['ctp'] = getgpc('ctp');
$filter['bid'] = getgpc('bid');
$filter['cid'] = getgpc('cid');
$filter['cen'] = getgpc('cen');

// if do not match
//右上和下面的筛选配合使用
$matchCtp = $filter['ctp'] && in_array($cartypeid, array(1,2,3)) && matchCTP($filter['ctp'], $cartypeid);
$matchCen = $filter['cen'] && $cartypeid == 4 && $filter['cen'] != 432;
//满足条件时,根据cookie传入的$cartypeid给 $filter赋值
if (!$matchCen && !$matchCtp) {
    if ($cartypeid == 1) {
//        $filter['ctp'] = 433;
        $localtypeid='433';
    }
    if ($cartypeid == 2) {
//        $filter['ctp'] = 434;
        $localtypeid='434';
    }
    if ($cartypeid == 3) {
//        $filter['ctp'] = 434;
        $localtypeid='0';
    }
    if ($cartypeid == 4) {
//        $filter['ctp'] = 434;
        $localtypeid='0';
    }
}
require_once DT_INC . '/search/listAuto.inc.php';
//$BRANDS_S =  $BRANDS ? $BRANDS : '';

if ($kw) {
	SearchCheck::length($kw);
	SearchCheck::timeLimit();
}

$total  = $db->count($table, $condition, $DT['cache_search']);
$do = new PriceModule($moduleid);
$pn = new Pagination();
$pn->recordsPerPage(60);
$pn->records($items);
//查询车的等级
$levels = PCache::read('autoCategory-level.php');
if ($total) {
    $local_lev = $levels[$localtypeid]['arrchildid'];
    $localarea_condition = "select * from xd_price p,xd_auto_rank_car r";
    $localarea_condition.=" where status=3 and  p.arcid = r.arid and r.level in ($local_lev) ";
    //如果选择的是全国
    if($cityid!=0){
        $localarea_condition.=" and areaid=".$cityid;
    }
    if ($kw) {
        $localarea_condition .= " AND title LIKE '%$kw%'";
    }
    $localarea_condition.=" order by p.edittime desc limit 60";
    $tags=$db->getAll($localarea_condition);
}

$seo_file = 'list';
include DT_INC.'/seo.inc.php';
include template('list', $module);

